package yaml

import (
	"io/ioutil"
	"log"
)

// see : https://cloud.tencent.com/developer/article/2003124
type conf struct {
	Enabled bool   `yaml:"enabled"` //yaml：yaml格式 enabled：属性的为enabled
	Path    string `yaml:"path"`
	Spring  RedisEntity
}

type RedisEntity struct {
	Redis RedisData
}
type RedisData struct {
	Host     string `json:"host"`
	Port     float64
	DataBase float64
	Timeout  float64
}

func GetConf(path string) conf {
	yamlFile, err := ioutil.ReadFile(path)
	if err != nil {
		log.Printf("yamlFile.Get err   #%v ", err)
	}
	c := conf{}
	err = yaml.Unmarshal(yamlFile, &c)
	if err != nil {
		log.Fatalf("Unmarshal: %v", err)
	}
	return c
}
